From 44c60036b5cfd588f6f8e80917b3d336e720aeed Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 2 Mar 2014 19:07:06 +0100 Subject: [PATCH] Use a secondary db connection for Revsion::getParentLength in api Getting api connection before the connection is set to the named connection and store it in a local var to use it later. Same comment as in Special:Contributions Bug: 61982 Change-Id: Ia66c4a65a24876e2a528034e8e003aa535e6b689 --- includes/api/ApiQueryUserContributions.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 9ad77d4860..16108a2c90 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -56,6 +56,11 @@ class ApiQueryContributions extends ApiQueryBase { $this->fld_patrolled = isset( $prop['patrolled'] ); $this->fld_tags = isset( $prop['tags'] ); + // Most of this code will use the 'contributions' group DB, which can map to slaves + // with extra user based indexes or partioning by user. The additional metadata + // queries should use a regular slave since the lookup pattern is not all by user. + $dbSecondary = $this->getDB(); // any random slave + // TODO: if the query is going only against the revision table, should this be done? $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' ); @@ -90,7 +95,7 @@ class ApiQueryContributions extends ApiQueryBase { $revIds[] = $row->rev_parent_id; } } - $this->parentLens = Revision::getParentLengths( $this->getDB(), $revIds ); + $this->parentLens = Revision::getParentLengths( $dbSecondary, $revIds ); $res->rewind(); // reset } -- 2.20.1